package com.ruoyi.eqmonitor.smdtv.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.eqmonitor.smdtv.domain.Smdtv8;
import com.ruoyi.eqmonitor.smdtv.mapper.Smdtv8Mapper;
import com.ruoyi.eqmonitor.smdtv.mapper.SmregisterMapper;
import com.ruoyi.eqmonitor.smdtv.service.ISmdtv8Service;
import com.ruoyi.eqmonitor.smdtv.vo.SumVo;
import com.ruoyi.eqmonitor.utils.Constant;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-01-09
 */
@Service
public class Smdtv8ServiceImpl extends ServiceImpl<Smdtv8Mapper,Smdtv8> implements ISmdtv8Service {

    @Resource
    private Smdtv8Mapper smdtv8Mapper;

    @Resource
    private SmregisterMapper smregisterMapper;

    @Override
    public Smdtv8 selectSmdtv8ById(Long id){
        return smdtv8Mapper.selectSmdtv8ById(id,smregisterMapper.getTableNameByDatasetName(Constant.Smregister.SMDTV_8.getName()));
    }

    @Override
    public List<Smdtv8> selectSmdtv8List(Smdtv8 smdtv8,Integer pageNum,Integer pageSize){
        return smdtv8Mapper.selectSmdtv8List(smdtv8,
                smregisterMapper.getTableNameByDatasetName(Constant.Smregister.SMDTV_8.getName()),
                pageNum,
                pageSize);
    }

    @Override
    public Long getTotal(Smdtv8 smdtv8) {
        return smdtv8Mapper.getTotal(smdtv8,
                smregisterMapper.getTableNameByDatasetName(Constant.Smregister.SMDTV_8.getName()));
    }

    @Override
    public SumVo getSum(String name) {
        SumVo sumVo = new SumVo();
        Long value = smregisterMapper.getSum(name,smregisterMapper.getTableNameByDatasetName(Constant.Smregister.SMDTV_8.getName()));
        sumVo.setName(Constant.Smregister.SMDTV_8.getName());
        sumVo.setValue(value);
        return sumVo;
    }

    @Override
    public List<Smdtv8> getByName(String name) {
        Smdtv8 smdtv8 = new Smdtv8();
        smdtv8.setName(name);
        return smdtv8Mapper.selectSmdtv8List(smdtv8,
                smregisterMapper.getTableNameByDatasetName(Constant.Smregister.SMDTV_8.getName()),
                null,null);
    }

    @Override
    public boolean save(Smdtv8 smdtv8) {
        return smdtv8Mapper.save(smdtv8,smregisterMapper.getTableNameByDatasetName(Constant.Smregister.SMDTV_8.getName())) > 0;
    }

    @Override
    public boolean updateById(Smdtv8 smdtv8) {
        return smdtv8Mapper.updateById(smdtv8,smregisterMapper.getTableNameByDatasetName(Constant.Smregister.SMDTV_8.getName())) > 0;
    }

    @Override
    public boolean removeByIds(List<Long> ids) {
        return smregisterMapper.removeByIds(ids,smregisterMapper.getTableNameByDatasetName(Constant.Smregister.SMDTV_8.getName())) > 0;
    }

}
